#!/bin/bash
# explain: Command-line wrapper for explainshell.com
# 
# Example usage: explain tar xzvf 
#
# Dependency: scrape (from: https://github.com/jeroenjanssens/dsutils)
#
# Author: http://jeroenjanssens.com


COMMAND="$@"
URL="http://explainshell.com/explain?cmd=${COMMAND}"
SYSTEM=$(uname)

if [[ "$SYSTEM" == "Linux" ]]
then
  curl -s "${URL}" | scrape -e 'span.dropdown > a, pre' | sed -re 's/<(\/?)[^>]*>//g'
elif [[ "$SYSTEM" == "Darwin" ]]
then
  curl -s "${URL}" | scrape -e 'span.dropdown > a, pre' | sed -Ee 's/<(\/?)[^>]*>//g'
fi




